﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
using System.Web.UI.DataVisualization.Charting;
using System.Data;
using System.Data.SqlClient;

public partial class Test1 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        float[] date = new float[] { 20, 40, 50, 80, 30, 10, 60, 30, 115 };
        float[] test = new float[] { 10, 80, 70, 40, 20, 50, 90, 13, 34 };
        Chart1.Width = 800;
        Chart1.Height = 400;
        Chart1.BackColor = Color.Azure;
        //建一个图表集合
        //Series series = new Series("test");
        //series.ChartType = SeriesChartType.Column;//图标集类型，Line为直线，spLine为曲线
        //series.Color =Color.Green;//线条颜色
        //series.BorderWidth = 1;//线条宽度
        //series.ShadowOffset = 1;//阴影宽度
        //series.IsVisibleInLegend = false;//是否显示数据说明
        //series.IsValueShownAsLabel = true;
        //series.MarkerStyle = MarkerStyle.Diamond;//线条上的数据点标志类型
        //series.MarkerSize = 8;//标志的大小

        //DateTime date1 = DateTime.Now.Date;
        //for (int i = 0; i < date.Length; i++)
        //{
        //    series.Points.AddXY(date1, date[i]);
        //    date1 = date1.AddDays(1);
        //}
        //Chart1.Series.Add(series);

        Series series1 = new Series("ok");
        series1.ChartType = SeriesChartType.Line;
        series1.Color = Color.Red;
        series1.BorderWidth = 2;
        series1.ShadowOffset = 1;
        series1.IsVisibleInLegend = false;
        series1.IsValueShownAsLabel = true;
        series1.MarkerStyle = MarkerStyle.Diamond;
        //DateTime date2 = DateTime.Now.Date;
        int a = 5;

        for (int i = 0; i < date.Length; i++)
        {
            series1.Points.AddXY(a, test[i]);
            //series1.Points.AddY(test[i]);
            //series1.Points.Add(date2);
            //date2 = date2.AddDays(1);
            a = a + 5;
        }
        Chart1.Series.Add(series1);


        Chart1.ChartAreas[0].AxisX.LineColor = Color.Blue;
        Chart1.ChartAreas[0].AxisX.LineWidth = 2;
        Chart1.ChartAreas[0].AxisY.LineColor = Color.Blue;
        Chart1.ChartAreas[0].AxisY.LineWidth = 2;
        Chart1.ChartAreas[0].AxisY.Title = "纵向距离（M）";
        Chart1.ChartAreas[0].AxisX.Title = "横向距离（M）";

        //Chart2.Width = 800;
        //Chart2.Height = 400;
        //Chart2.BackColor = Color.Azure;
        //Chart2.Titles.Add("医药品销售情况");
        //SqlDataReader da = getdata();
        //Chart2.DataBindTable(da, "ordername");

        //// Chart2.Series[1].Color = Color.Blue;
        //Chart2.Series[1].IsValueShownAsLabel = true;
        //Chart2.Series[1].IsVisibleInLegend = false;//是否显示数据说明
        //Chart2.Series[1].MarkerStyle = MarkerStyle.Circle;
        //Chart2.Series[1].MarkerSize = 8;

        //Chart2.ChartAreas[0].AxisX.LineWidth = 2;
        //Chart2.ChartAreas[0].AxisX.LineColor = Color.Blue;
        //Chart2.ChartAreas[0].AxisY.LineWidth = 2;
        //Chart2.ChartAreas[0].AxisY.LineColor = Color.Blue;
        //Chart2.ChartAreas[0].AxisY.Title = "纵向距离（M）";
        //Chart2.ChartAreas[0].AxisX.Title = "横向距离（M）";


        Series series3 = Chart3.Series.Add("my series");
        series3.ToolTip = "#VALX:#VAL{C} million";
        series3.Label = "#VALX:#VAL{C} million";
        //series3.LegendToolTip = "#PERCENT";
        series3.PostBackValue = "#INDEX";
        series3.LegendPostBackValue = "#INDEX";
        double[] yValues = new double[] { 23.3, 33.6, 65.6, 45.6, 23.89, 43.23, 23.3, 33.6, 65.6, 45.6, 23.89, 43.23, 23.3, 33.6, 65.6, 45.6, 23.89, 43.23, 23.3, 33.6, 65.6, 45.6, 23.89, 43.23, 23.3, 33.6, 65.6, 45.6, 23.89, 43.23, 23.3, 33.6, 65.6, 45.6, 23.89, 43.23, 23.3, 33.6, 65.6, 45.6, 23.89, 43.23, 23.3, 33.6, 65.6, 45.6, 23.89, 43.23, 23.3, 33.6, 65.6, 45.6, 23.89, 43.23, 23.3, 33.6, 65.6, 45.6, 23.89, 43.23, 23.3, 33.6, 65.6, 45.6, 23.89, 43.23, 23.3, 33.6, 65.6, 45.6, 23.89, 43.23, 23.3, 33.6, 65.6, 45.6, 23.89, 43.23, 23.3, 33.6, 65.6, 45.6, 23.89, 43.23, 23.3, 33.6, 65.6, 45.6, 23.89, 43.23, 23.3, 33.6, 65.6, 45.6, 23.89, 43.23 };
        string[] xValues = new string[] { "马竞", "塞维利亚", "巴塞罗那", "皇家马德里", "皇家贝蒂斯", "瓦伦西亚", "马竞", "塞维利亚", "巴塞罗那", "皇家马德里", "皇家贝蒂斯", "瓦伦西亚", "马竞", "塞维利亚", "巴塞罗那", "皇家马德里", "皇家贝蒂斯", "瓦伦西亚", "马竞", "塞维利亚", "巴塞罗那", "皇家马德里", "皇家贝蒂斯", "瓦伦西亚", "马竞", "塞维利亚", "巴塞罗那", "皇家马德里", "皇家贝蒂斯", "瓦伦西亚", "马竞", "塞维利亚", "巴塞罗那", "皇家马德里", "皇家贝蒂斯", "瓦伦西亚", "马竞", "塞维利亚", "巴塞罗那", "皇家马德里", "皇家贝蒂斯", "瓦伦西亚", "马竞", "塞维利亚", "巴塞罗那", "皇家马德里", "皇家贝蒂斯", "瓦伦西亚", "马竞", "塞维利亚", "巴塞罗那", "皇家马德里", "皇家贝蒂斯", "瓦伦西亚", "马竞", "塞维利亚", "巴塞罗那", "皇家马德里", "皇家贝蒂斯", "瓦伦西亚", "马竞", "塞维利亚", "巴塞罗那", "皇家马德里", "皇家贝蒂斯", "瓦伦西亚", "马竞", "塞维利亚", "巴塞罗那", "皇家马德里", "皇家贝蒂斯", "瓦伦西亚", "马竞", "塞维利亚", "巴塞罗那", "皇家马德里", "皇家贝蒂斯", "瓦伦西亚", "马竞", "塞维利亚", "巴塞罗那", "皇家马德里", "皇家贝蒂斯", "瓦伦西亚", "马竞", "塞维利亚", "巴塞罗那", "皇家马德里", "皇家贝蒂斯", "瓦伦西亚", "马竞", "塞维利亚", "巴塞罗那", "皇家马德里", "皇家贝蒂斯", "瓦伦西亚" };
        series3.Points.DataBindXY(xValues, yValues);
        series3.ChartType = SeriesChartType.Pie;
        //series3.CustomProperties = "LableStyle=OutSide";
        series3.ShadowOffset = 2;
        series3.IsValueShownAsLabel = true;
        
        Chart3.Width = 1000;
        Chart3.Height = 800;
        Chart3.Titles.Add("2012西甲各球队上座率");
        Chart3.Series["my series"]["PieLabelStyle"] = "Outside";
        Chart3.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;
    }

    ////读取数据库
    //private SqlDataReader getdata()
    //{
    //    SqlConnection con = new SqlConnection("server=.;database=IFCANet_R2_8_WanDa_SEMS;uid=sa;pwd=allen");
    //    SqlCommand com = new SqlCommand("SELECT ProductName AS ordername, ProductTypeID AS ordercount FROM dbo.SE_ProductType", con);
    //    con.Open();
    //    DataSet ds = new DataSet();
    //    SqlDataReader da = com.ExecuteReader();
    //    return da;
    //}
    protected void Chart3_Click(object sender, ImageMapEventArgs e)
    {
        int pointindex = int.Parse(e.PostBackValue);
        Series series = Chart3.Series["my series"];
        if (pointindex >= 0 && pointindex <= series.Points.Count)
        {
            series.Points[pointindex].CustomProperties += "Exploded=true";
        }

    }
}